﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ATM
{
    public partial class TransferBalnace : Form
    {
        AccountLogic ca = new AccountLogic();
        public string acN, reciverN;
        string money;
        public TransferBalnace(string acc)
        {
            InitializeComponent();
            acN = acc;
        }

        private void transfer_Click(object sender, EventArgs e)
        {
            // acN is the account number of the sender, ID is the account number of the receiver, and balan is the ammount of money
            if (ID.Text != "" && balan.Text != "")
            {   
                reciverN = ID.Text;
                money = balan.Text;

                ca.tranferB(acN, reciverN, money);
                if (ca.check == 1)
                {
                    if (ca.information == 1)
                    {

                        inter_face i = new inter_face(acN);
                        i.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Your balance must be not enough or this wrond ID sir !!");
                        ID.Text = "";
                        balan.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("You must enter valid numbers");
                    ID.Text = "";
                    balan.Text = "";
                }
            
            }

            else
                MessageBox.Show("You must enter both reciver AccountID and the balance !");
        }

        private void back_Click(object sender, EventArgs e)
        {
            inter_face inter = new inter_face(acN);
            inter.Show();
            this.Hide();
        }
        private void label_Click(object sender, EventArgs e)
        {
            Label b = (Label)sender;
         
            if (ID.Focused == true)
            {
                
                ID.Text = ID.Text + b.Text;
            }
            else if (balan.Focused == true)
            {
               
                balan.Text = balan.Text + b.Text;
            }
        }

        private void exit_Click(object sender, EventArgs e)
        {
            welcom w = new welcom();
            w.Show();
            this.Hide();
        }

        private void cld_Click(object sender, EventArgs e)
        {
            ID.Text = "";
        }

        private void cba_Click(object sender, EventArgs e)
        {
            balan.Text = "";
        }

      
    }
}
